
Type Entity Extends BaseObject
	
	Function getFromHandle:Entity(hnd:Int)
		Return Entity(HandleToObject(hnd))
	End Function
	
rem
bbdoc: Sets the position of the node relative to it's parent. 
endrem
	Method SetPosition(x:Float, y:Float, z:Float)
		o_scenenode_setposition(o_entity_getParentSceneNode(Self._ptr), x, y, z)
	End Method
	
	
	Method translate(x:Float, y:Float, z:Float, relativeTo:Int = TS_PARENT)
		o_scenenode_translate(o_entity_getParentSceneNode(Self._ptr), x, y, z, relativeTo)
	End Method
	
	
	Method pitch(radian:Float, relativeTo:Int = TS_PARENT)
		o_scenenode_pitch(o_entity_getParentSceneNode(Self._ptr), radian, relativeTo)
	End Method
	
	
	Method yaw(radian:Float, relativeTo:Int = TS_PARENT)
		o_scenenode_yaw(o_entity_getParentSceneNode(Self._ptr), radian, relativeTo)
	End Method
	
	
	Method roll(radian:Float, relativeTo:Int = TS_PARENT)
		o_scenenode_roll(o_entity_getParentSceneNode(Self._ptr), radian, relativeTo)
	End Method
	
	
	Method Turn(x:Float, y:Float, z:Float, relativeTo:Int = TS_PARENT)
		o_scenenode_pitch(o_entity_getParentSceneNode(Self._ptr), x, relativeTo)
		o_scenenode_yaw(o_entity_getParentSceneNode(Self._ptr), y, relativeTo)
		o_scenenode_roll(o_entity_getParentSceneNode(Self._ptr), z, relativeTo)
	End Method
	
rem
bbdoc: Gets the position of the node relative to it's parent. 
endrem
	Method GetPosition:bVector3()
		Local vec:bVector3 = bVector3.NullVec()
		Local vecp:Byte ptr = o_scenenode_getposition(o_entity_getParentSceneNode(Self._ptr))
		vec.x = Float ptr(vecp)[0]
		vec.y = Float ptr(vecp)[1]
		vec.z = Float ptr(vecp)[2]
		
		Return vec
	End Method
	
rem
bbdoc: Sets whether or not this object will cast shadows.
about: <p>This setting simply allows you to turn on/off shadows for a given object. An object will 
not cast shadows unless the scene supports it in any case (see SceneManager::setShadowTechnique), 
and also the material which is in use must also have shadow casting enabled. By default all 
entities cast shadows. If, however, for some reason you wish to disable this for a single object 
then you can do so using this method.</p>
<b><b>Note:</b> This method normally refers to objects which block the light, but since Light is 
also a subclass of MovableObject, in that context it means whether the light causes shadows itself.</p>
endrem
	Method setCastShadows(enable:Byte)
		o_entity_setCastShadows(Self._ptr, enable)
	End Method
	
rem
bbdoc: Clones this entity and returns a pointer to the clone. 
about: Useful method for duplicating an entity. The new entity must be given a unique name, and 
is not attached to the scene in any way so must be attached to a SceneNode to be visible 
(exactly as entities returned from SceneManager::createEntity). 
endrem
	Method clone:Entity(newName:String = "")
		If newName = "" Then newName = Root.genName()
		Local e:Entity = New Entity
		e._ptr = o_clone(Self._ptr, newName)
		e._typ = ET_ENTITY
		
		Return e
	End Method
	
rem
bbdoc: Sets the material to use for the whole of this entity.
about: This is a shortcut method to set all the materials for all subentities of this entity. 
Only use this method is you want to set the same material for all subentities or if you know 
there is only one. Otherwise call getSubEntity()  and call the same method on the individual 
SubEntity. 
endrem
	Method setMaterialName(matName:String, resGroup:String = "AUTODETECT_RESOURCE_GROUP_NAME")
		o_entity_setMaterialName(Self._ptr, matName.ToCString(), resGroup.ToCString())
	End Method
	
rem
bbdoc: Sets the material to use for the whole of this entity. 
about: This is a shortcut method to set all the materials for all subentities of this entity. 
Only use this method is you want to set the same material for all subentities or if you know 
there is only one. Otherwise call getSubEntity()  and call the same method on the individual 
SubEntity. 
endrem
	Method SetMaterial(mat:Material)
		o_entity_setMaterial(Self._ptr, mat._ptr)
	End Method
	
rem
bbdoc: Retrieves a weak reference to the material this renderable object uses.
about: Note that the Renderable also has the option to override the getTechnique method to 
specify a particular Technique to use instead of the best one available. 
endrem
	Method GetMaterial:Material(subEntity:Int = 0)
		Local mat:Material = New Material
		mat._ptr	= o_entity_getMaterial(Self._ptr, subEntity)
		mat._typ	= ET_NO_ENTITY
		
		Return mat
	End Method
	
rem
bbdoc: Gets the Mesh  that this Entity is based on. 
endrem
	Method getMesh:Mesh()
		Local m:Mesh = New Mesh
		m._ptr = o_entity_getMesh(Self._ptr)
		m._typ = ET_MESH
		
		Return m
	End Method
	
rem
bbdoc: Get the axis-aligned bounding box for this mesh. 
endrem
	Method getBounds:AxisAlignedBox()
		Local box:AxisAlignedBox = New AxisAlignedBox
		box._ptr = o_mesh_getBounds(Self._ptr)
		Return box
	End Method
	
	Method SetOrientation(orientation:bQuaternion)
		o_scenenode_setOrientation(o_entity_getParentSceneNode(Self._ptr), orientation.toC())
	End Method
End Type